import { find } from 'lodash';

export const formList = [];

export const getTableColumns = ({taskTypeList}: any) => [
	{
		title: "任务ID",
		dataIndex: "id",
		ellipsis: true
	},
	{
		title: "任务名称",
		dataIndex: "jobName",
		ellipsis: true
	},
	{
		title: "任务类型",
		dataIndex: "jobType",
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(taskTypeList || [], (item: any) => item.value === record.jobType)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "优先级",
		dataIndex: "level",
		ellipsis: true
	},
];

export const USER_STATUS = [
	{ label: '在线', value: 1 },
	{ label: '离线', value: 2 }
]

export const getSearchColumns = () => [
	{
		type: "input",
		placeholder: "用户名",
		name: "keyword"
	},
	{
		type: "select",
		placeholder: "所属组织",
		name: "keyword"
	},
	{
		type: "input",
		placeholder: "角色",
		name: "keyword"
	},
	{
		type: "select",
		placeholder: "用户状态",
		name: "keyword",
		options: USER_STATUS
	},
]



export const SORT_LIST = [
	{ label: '1', value: 1 },
	{ label: '2', value: 2 },
	{ label: '3', value: 3 }
]

export const getCreateColumns = ({taskTypeList, loopList}: {taskTypeList: any, loopList: any}) => {
	return [
		{
			type: "input",
			placeholder: "任务名称",
			label: "任务名称",
			name: "jobName",
			rules: [{ required: true, message: '这是必填项' }]
		},
		{
			type: "select",
			placeholder: "任务类型",
			label: "任务类型",
			name: "jobType",
			rules: [
				{ required: true, message: '这是必填项' },
			],
			options: taskTypeList,
			fieldProps: {
				fieldNames: {
					label: 'label',  // 显示文本对应的字段
					value: 'value',    // 值对应的字段
				}
			}
		},
		{
			type: "select",
			placeholder: "业务环线",
			label: "业务环线",
			name: "loopId",
			rules: [
				{ required: true, message: '这是必填项' },
			],
			options: loopList,
			fieldProps: {
				fieldNames: {
					label: 'loopName',  // 显示文本对应的字段
					value: 'id',    // 值对应的字段
				}
			}
		},
		{
			type: "select",
			placeholder: "优先级",
			label: "优先级",
			name: "level",
			rules: [{ required: true, message: '这是必填项' }],
			options: SORT_LIST,
			fieldProps: {
				fieldNames: {
					label: 'label',  // 显示文本对应的字段
					value: 'value',    // 值对应的字段
				}
			}
		},
	]
}